package com.siki.vo;

import com.siki.pojo.model.DepartmentInformation;
import com.siki.pojo.model.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @Author Siki
 * @Date 2020/4/24
 */
@ApiModel("报名信息列表返回VO")
@Getter
@Setter
@NoArgsConstructor
public class UserListInfoVO {
    @ApiModelProperty("id")
    String id;

    @ApiModelProperty("姓名")
    String name;

    @ApiModelProperty("报名岗位")
    List<UserIntentionListVO> intention;

    @ApiModelProperty("个人信息")
    String classInfo;

    @ApiModelProperty("备注")
    String remark;

    public UserListInfoVO(User user) {
        Optional.ofNullable(user).ifPresent(u -> {
            this.id = u.getId();
            this.name = u.getName();
            this.intention = UserIntentionListVO.getList(u.getDepartmentInformationList());
            this.classInfo = u.getClassInfo();
            List<String> collect = u.getDepartmentInformationList().stream()
                    .filter(departmentInformation -> Objects.nonNull(departmentInformation.getRemark()))
                    .map(DepartmentInformation::getRemark)
                    .filter(s -> (!s.isEmpty() && !s.equals("")))
                    .collect(Collectors.toList());
            if (collect.size() >= 1) {
                this.remark = collect.get(0);
            }
        });
    }
}


















